package top.kaoshanji.r5ch12d;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

/**
 * @author kaoshanji
 * ^_^
 * create time 2025/5/11 10:17
 */
@Service("scoreUserService")
public class ScoreService extends BaseService {

    private JdbcTemplate jdbcTemplate;

    @Autowired
    public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }

    public void addScore(String userName, int toAdd) {
        String sql = " UPDATE t_user1 u SET u.score = u.score + ? WHERE user_name =? ";
        jdbcTemplate.update(sql, toAdd, userName);
    }

}
